(function () {
    angular.module('app')
        .component('xxShowAllQuestionByConsultantId', {
            templateUrl: '/app/consultant/showAllQuestionByConsultantId/showAllQuestionByConsultantId.html',
            controller: ctrl
        });

    function ctrl($scope,$state,$stateParams,userService,ShowAllQuestionByConsultantIdFactory) {
        /**
         * purpose:http post
         */
        // $scope.allEssay = [];
        $scope.allAnsweredEssay = [];
        $scope.allUnAnsweredEssay = [];

        var consultantId = $stateParams.consultantId;

        /*已回答*/
        function showAllAnsweredQuestionByConsultantId(consultantId) {
            function cb(err,res) {
                if(!err)$scope.allAnsweredEssay = res['msg'];
                //console.log(res);
            }
            ShowAllQuestionByConsultantIdFactory.showAllAnsweredQuestionByConsultantId(consultantId,cb);
        }
        showAllAnsweredQuestionByConsultantId(consultantId);

        /*未回答*/
        function showAllUnAnsweredQuestionByConsultantId(consultantId) {
            function cb(err,res) {
                if(!err)$scope.allUnAnsweredEssay = res['msg'];
                //console.log(res);
            }
            ShowAllQuestionByConsultantIdFactory.showAllUnAnsweredQuestionByConsultantId(consultantId,cb);
        }
        showAllUnAnsweredQuestionByConsultantId(consultantId);

        $scope.getEssayById = function (essayId) {
            $state.go("show.get-essay-by-id",{essayId:essayId});
        }
    }
})();
